package com.rhem.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.ScrollPanel;

public class RhemSol implements EntryPoint,ValueChangeHandler<String> {
	RootLayoutPanel root;
	private static RhemSol singleton;	
	
	public static RhemSol get() {
	  return singleton;
	}
	
	
	interface RhemSolUiBinder extends UiBinder<ScrollPanel, RhemSol> {}

	private static final RhemSolUiBinder binder = GWT.create(RhemSolUiBinder.class);
	
	public void onModuleLoad() {
		System.out.println("Iniciado1");
		singleton = this;
	   
		ScrollPanel outer = binder.createAndBindUi(this);
	    root = RootLayoutPanel.get();
	    root.add(outer);
		System.out.println("Iniciado2");
		
		String startingToken = History.getToken();
		History.addValueChangeHandler(this);
		History.newItem(startingToken, true);		
	}

	@Override
	public void onValueChange(ValueChangeEvent<String> event) {
		// TODO Auto-generated method stub
		//Window.alert(GWT.getHostPageBaseURL());
		/*Hyperlink link = (Hyperlink)event.getSource();
		
		DOM.getParent(link.getElement());
		Window.alert(event.getValue());*/
	}	
	
}
